import request from '../utils/request';

export const fetchData = () => {
    return request({
        url: './table.json',
        method: 'get'
    });
};

// 登录
export const loginApi = (param: any) => {
    return request({
        url: '/web-user/login',
        method: 'post',
        data: param
    });
};

// 注册
export const registerApi = (param: any) => {
    return request({
        url: '/web-user/register',
        method: 'post',
        data: param
    });
};

// 注册
export const passwordApi = (param: any) => {
    return request({
        url: '/web-user/password',
        method: 'put',
        data: param
    });
};


// 寄件（添加快递）
export const addExpress = (param: any) => {
    return request({
        url: '/order',
        method: 'post',
        data: param
    });
};

// 快件类型选项
export const getTypeOptions = () => {
    return request({
        url: '/type/options',
        method: 'get',
    });
};

// 订单列表(默认添加身份条件)
export const getOrderListApi = (param: any) => {
    return request({
        url: '/order',
        method: 'get',
        params: param
    });
};

// 订单列表(快递员使用)
export const getOrderListByCourierApi = (param: any) => {
    return request({
        url: '/order/listByCourier',
        method: 'get',
        params: param
    });
};

// 订单列表(不添加身份条件)
export const getReceiveOrderListApi = (param: any) => {
    return request({
        url: '/order/listReceive',
        method: 'get',
        params: param
    });
};

// 订单详细
export const getOrderDetailApi = (param: any) => {
    return request({
        url: '/order/detail',
        method: 'get',
        params: param
    });
};
// 操作日志
export const getLogListApi = (param: any) => {
    return request({
        url: '/express/sys-log',
        method: 'get',
        params: param
    });
};

// 更新订单
export const updateOrderApi = (param: any) => {
    return request({
        url: '/order',
        method: 'put',
        data: param
    });
};

// 操作订单
export const operateOrderApi = (param: any) => {
    return request({
        url: '/order/operate',
        method: 'put',
        data: param
    });
};

// 订单批量操作
export const batchOperateOrderApi = (param: any) => {
    return request({
        url: '/order/batch-operate/' + param,
        method: 'put',
    });
};

// 用户拒收订单
export const refuseOrderApi = (param: any) => {
    return request({
        url: '/order/refuse/' + param,
        method: 'put',
    });
};

//用户管理
// 示例列表
export const getWebUserListApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'get',
        params: param
    });
};


// 示例新增
export const addWebUserApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'post',
        data: param
    });
};

// 示例修改
export const updateWebUserApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'put',
        data: param
    });
};

// 示例删除
export const deleteWebUserApi = (id: number) => {
    return request({
        url: '/web-user/' + id,
        method: 'delete'
    });
};

// 快递类型列表
export const getTypeListApi = (param: any) => {
    return request({
        url: '/type',
        method: 'get',
        params: param
    });
};


// 快递类型新增
export const addTypeApi = (param: any) => {
    return request({
        url: '/type',
        method: 'post',
        data: param
    });
};

// 快递类型修改
export const updateTypeApi = (param: any) => {
    return request({
        url: '/type',
        method: 'put',
        data: param
    });
};

// 快递类型删除
export const deleteTypeApi = (id: number) => {
    return request({
        url: '/type/' + id,
        method: 'delete'
    })
};

// 网点列表
export const getOutletListApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'get',
        params: param
    });
};

// 网点新增
export const addOutletApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'post',
        data: param
    });
};

// 网点修改
export const updateOutletApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'put',
        data: param
    });
};

// 网点删除
export const deleteOutletApi = (id: number) => {
    return request({
        url: '/outlet/' + id,
        method: 'delete'
    });
};

// 地址簿列表
export const getAddressBookListApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'get',
        params: param
    });
};


// 地址簿新增
export const addAddressBookApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'post',
        data: param
    });
};

// 地址簿修改
export const updateAddressBookApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'put',
        data: param
    });
};

// 地址簿删除
export const deleteAddressBookApi = (id: number) => {
    return request({
        url: '/address-book/' + id,
        method: 'delete'
    });
};

// 数据大屏
export const getDashboardApi = (param: any) => {
    return request({
        url: '/order/dashboard',
        method: 'get',
        params: param
    });
};